package com.iuie.ns.frame.free.excel.beans;

import java.util.Map;

/**
 * 工作表每一列的样式定义
 * @author liujie
 * @date 2018年5月13日下午4:27:30
 */
public class SheetColumn {

	/** 水平居左 */
	public static final int ALIGN_LEFT=-1;
	
	/** 水平居中 */
	public static final int ALIGN_CENTER=0;
	
	/** 水平居右 */
	public static final int ALIGN_RIGHT=1;
	
	/** 列名，表头（表格第一行）上显示的名称 */
	private String columnName;
	/** 表格中的数据的列的字段名
	 * <p><b>解释：</b>如List&lt;UserVO&gt; lst是要渲染的数据，其中有字段<BR>
	 * String username,<BR>String userAccount,<BR>int userAge<BR>三个字段，
	 * 那么username：用户名，userAccount：用户账号，userAge：年龄，其中的username
	 * 就是这儿的columnKey，用户名就是columnName</p> 
	 */
	private String columnKey;
	
	/** 定义表格每一列的宽度 */
	private int columnWidth;
	
	/** 定义数据在表格中的水平方向的排列方式：居左|居中|居右，默认居左*/
	private int align=ALIGN_LEFT;
	
	/** 权重，设置列的排序顺序 */
	private int weight=-1;

	public SheetColumn(String columnKey, String columnName) {
		this.columnKey = columnKey;
		this.columnName = columnName;
	}
	
	public SheetColumn(String columnKey, String columnName, int columnWidth) {
		this.columnKey = columnKey;
		this.columnName = columnName;
		this.columnWidth = columnWidth;
	}
	
	public SheetColumn(String columnKey, String columnName, int columnWidth,int align) {
		this.columnKey = columnKey;
		this.columnName = columnName;
		this.columnWidth = columnWidth;
		this.align = align;
	}
	
	public SheetColumn(String columnKey, String columnName, int columnWidth,int align, int weight) {
		this.columnKey = columnKey;
		this.columnName = columnName;
		this.columnWidth = columnWidth;
		this.align = align;
		this.weight = weight;
	}
	
	public String getColumnKey() {
		return columnKey;
	}

	public String getColumnName() {
		return columnName;
	}

	public void setColumnKey(String columnKey) {
		this.columnKey = columnKey;
	}

	public void setColumnName(String columnName) {
		this.columnName = columnName;
	}

	public int getColumnWidth() {
		return columnWidth;
	}

	public void setColumnWidth(int columnWidth) {
		this.columnWidth = columnWidth;
	}
	public <E> E getAlign(Map<Integer, E> relations) {
		return relations.get(this.align);
	}                                                                                                                                              
	public void setAlign(int align) {
		this.align = align;
	}
	public int getWeight() {
		return weight;
	}
	public void setWeight(int weight) {
		this.weight = weight;
	}
	public String getMethodNameByColumnKey(){
		return "get" + columnKey.substring(0, 1).toUpperCase()+columnKey.substring(1);
	}
}
